home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / doom / turric03.zip / TURRIC03.ZIP / PROGS / CHAIN.QC < prev    next >
Text File  |  1997-02-06  |  8KB  |  303 lines

  1. /*
  2. ==============================================================================
  3.  
  4. MORNING STAR
  5.  
  6. ==============================================================================
  7. */
  8.  
  9. /*
  10.  
  11. hook.dest = Last Origin of Owner
  12. hook.style = Current chain sound
  13.  
  14. */
  15.  
  16.  
  17. /************\
  18. * BreakChain *
  19. \************/
  20.  
  21. void (entity Head) BreakChain =
  22. {
  23.         local entity link;
  24.  
  25.         link = Head.goalentity;
  26.         while (link != world)
  27.         {
  28.                 Head = link.goalentity;
  29.                 remove (link);
  30.                 link = Head;
  31.         }
  32. };
  33.  
  34. /*********\
  35. * LinkPos *
  36. \*********/
  37.  
  38. void () LinkPos =
  39. {
  40.         makevectors (self.enemy.angles);
  41.         setorigin (self, self.owner.origin + ( ( ( self.enemy.origin + 
  42.                 (v_up * 20 * (!self.enemy.button2)) + (v_forward * 16) ) - self.owner.origin ) *
  43.                 ( self.weapon ) ) );
  44.         self.nextthink = time + 0.01;
  45. };
  46.  
  47. /***********\
  48. * MakeChain *
  49. \***********/
  50.  
  51. entity (entity head, entity tail, float num) MakeChain =
  52. {
  53.         local entity link, prevlink;
  54.         local float linknum;
  55.  
  56.         linknum = num;
  57.         num = num + 1;
  58.         prevlink = world;
  59.         while (linknum > 0)
  60.         {
  61.                 link = spawn();
  62.  
  63.                 link.goalentity = prevlink;
  64.                 prevlink = link;
  65.  
  66.                 link.owner = head;
  67.                 link.enemy = tail;
  68.                 link.weapon = linknum / num;
  69.                 link.movetype = MOVETYPE_NOCLIP;
  70.                 link.solid = SOLID_NOT;
  71.                 link.angles_z = 51 * linknum;
  72.                 link.angles_y = 41 * linknum;
  73.                 link.angles_x = 31 * linknum;
  74.                 link.avelocity = '310 410 510';
  75.                 setmodel (link, "progs/bit.mdl");
  76.                 setsize (link, '0 0 0', '0 0 0');
  77.                 makevectors (tail.angles);
  78.                 setorigin (link, head.origin + ( ( ( tail.origin
  79.                         + (v_up * 20 * (!tail.button2)) + ( v_forward * 16 ) ) - head.origin )
  80.                         * ( link.weapon ) ) );
  81.                 link.nextthink = time + 0.01;
  82.                 link.think = LinkPos;
  83.                 linknum = linknum - 1;
  84.         }
  85.         return link;
  86. };
  87.  
  88.  
  89. /************\
  90. * HookVanish *
  91. \************/
  92.  
  93. void () HookVanish =
  94. {
  95.         self.owner.hook_out = FALSE;
  96.         if (self.enemy.classname == "player")
  97.                 self.enemy.attack_finished = time + 0.1;
  98.         sound (self.owner, CHAN_WEAPON, "weapons/bounce2.wav", 1, ATTN_NORM);
  99.         BreakChain (self);
  100.         remove (self);
  101. };
  102.  
  103. /**********\
  104. * HookPull *
  105. \**********/
  106.  
  107. void () HookPull =
  108. {
  109.         local vector vel, spray;
  110.         local float v, dorg;
  111.  
  112.         if ((!self.owner.button0 && (self.owner.weapon == IT_MORNINGSTAR)) ||
  113.                 (self.owner.teleport_time > time ) || self.owner.deadflag )
  114.         {
  115.                 if (self.enemy.takedamage && (self.weapon > 0))
  116.                 {       self.enemy.nextthink = time + 0.1; }
  117.                 HookVanish();
  118.                 return;
  119.         }
  120.         else
  121.         {
  122.                 makevectors (self.owner.angles);
  123.                 vel = self.origin - ( self.owner.origin + (v_up * 20 *
  124.                         ((1.25 * (!self.owner.button2)) - 0.25)) + (v_forward
  125.                         * 16));
  126.                 v = vlen (vel);
  127.                 if (v <= 100)
  128.                         vel = normalize(vel) * v * 10;
  129.                 else
  130.                         vel = normalize(vel) * 1000;
  131.                 dorg = vlen (self.owner.origin - self.dest);
  132.                 if ( ( dorg > 10 ) && (self.style == 3) )
  133.                 {
  134.                         sound (self.owner, CHAN_WEAPON, "weapons/chain2.wav", 1, ATTN_NORM);
  135.                         self.style = 2;
  136.                 }
  137.                 if ( (dorg < 10) && (self.style == 2) )
  138.                 {
  139.                         sound (self.owner, CHAN_WEAPON, "weapons/chain3.wav", 1, ATTN_NORM);
  140.                         self.style = 3;
  141.                 }
  142.                 self.owner.velocity = vel;
  143.                 self.dest = self.owner.origin;
  144.                 if (self.enemy.takedamage)
  145.                 {
  146.                         sound (self, CHAN_WEAPON, "blob/land1.wav", 1, ATTN_NORM);
  147.                         T_Damage (self.enemy, self, self.owner, 1);
  148.                         makevectors (self.v_angle);
  149.                         spray_x = 100 * crandom();
  150.                         spray_y = 100 * crandom();
  151.                         spray_z = 100 * crandom() + 50;
  152.                         SpawnBlood (self.origin, spray, 20);
  153.                         if (self.weapon > 0)
  154.                         {
  155.                                 self.enemy.nextthink = time + 9999999;
  156.                                 if (self.enemy.classname == "player")
  157.                                         self.enemy.attack_finished = time + 9999999;
  158.                         }
  159.                         if (self.enemy.health <= 0)
  160.                         {
  161.                                 if (self.weapon > 0)
  162.                                         self.enemy.nextthink = time + 0.1;
  163.                         }
  164.                         if (self.enemy.solid == SOLID_SLIDEBOX)
  165.                         {
  166.                                 self.velocity = '0 0 0';
  167.                                 setorigin (self, self.enemy.origin +
  168.                                         self.enemy.mins +
  169.                                         (self.enemy.size * 0.5));
  170.                         }
  171.                         else
  172.                         {
  173.                                 self.velocity = self.enemy.velocity;
  174.                         }
  175.                 }
  176.                 else
  177.                 {
  178.                         self.velocity = self.enemy.velocity;
  179.                 }
  180.                 if (self.enemy.solid == SOLID_NOT)
  181.                 {
  182.                         HookVanish();
  183.                         return;
  184.                 }
  185.                 self.nextthink = time + 0.1;
  186.                 self.think = HookPull;
  187.         }
  188. };
  189.  
  190. /**************\
  191. * T_ChainTouch *
  192. \**************/
  193.  
  194. void() T_ChainTouch =
  195. {
  196. // See below for gotcha.wav
  197. //        local float rand;
  198.  
  199.     if (other == self.owner)
  200.         return;         // don't attach to owner
  201.  
  202.     if (pointcontents(self.origin) == CONTENT_SKY)
  203.     {
  204.         HookVanish();
  205.         return;
  206.     }
  207.  
  208. //** PATCH_BEGIN - grap109b - Turrican ****
  209.     if (other.takedamage)
  210.     {
  211.         SpawnBlood (self.origin, self.velocity, 10);
  212.         sound (self, CHAN_AUTO, "zombie/z_hit.wav", 1, ATTN_NORM);
  213.         if (other.classname == "player")
  214.         {
  215.             SpawnChunk (self.origin,self.velocity);
  216.             other.punchangle_x = -15;
  217.             other.axhitme = 1;
  218.         }
  219.         T_Damage (other, self, self.owner, 10 );
  220.         HookVanish();
  221.         return;
  222.     }
  223.     else
  224.     {
  225.         self.avelocity = '0 0 0';
  226.         sound (self, CHAN_AUTO, "weapons/bounce.wav", 1, ATTN_NORM);
  227.     }
  228. //** PATCH_END - grap109b - Turrican ******
  229.  
  230.     if (!self.owner.button0)
  231.     {
  232.         HookVanish();
  233.         return;
  234.     }
  235.     else
  236.     {
  237.         if (other.solid == SOLID_SLIDEBOX)
  238.         {
  239.             setorigin (self, other.origin + other.mins + (other.size * 0.5));
  240.             self.velocity = '0 0 0';
  241.  
  242. //** PATCH_BEGIN - grap109b - Turrican ****
  243. // Commented this out 'cos it annoyed me.
  244. //                        rand = random();
  245. //                        if (rand <= (vlen(other.origin - self.owner.origin) * 0.001))
  246. //                                sound (self.owner, CHAN_VOICE, "weapons/gotcha.wav",
  247. //                                1, ATTN_STATIC);
  248. //** PATCH_END - grap109b - Turrican ******
  249.         }
  250.         else
  251.         {
  252.             self.velocity = other.velocity;
  253.         }
  254.  
  255.         self.weapon = other.nextthink - time;
  256.         sound (self.owner, CHAN_WEAPON, "weapons/chain2.wav", 1, ATTN_NORM);
  257.         self.style = 2;
  258.         self.enemy = other;
  259.         self.think = HookPull;
  260.         self.nextthink = time + 0.1;
  261.         self.touch = SUB_Null;
  262.     }
  263. };
  264.  
  265. /*************\
  266. * W_FireChain *
  267. \*************/
  268.  
  269. void() W_FireChain =
  270. {
  271.         local entity hook;
  272.  
  273.         self.hook_out = TRUE;
  274.         hook = spawn ();
  275.         hook.owner = self;
  276.         hook.movetype = MOVETYPE_FLY;
  277.         hook.solid = SOLID_BBOX;
  278.         
  279. // set hook speed 
  280.  
  281.         makevectors (self.v_angle);
  282.         hook.velocity = aim(self, 1000);
  283.         hook.velocity = hook.velocity * 1000;
  284.         hook.angles = vectoangles(hook.velocity);
  285.         hook.avelocity = '0 0 -500';
  286.     
  287.         hook.touch = T_ChainTouch;
  288.  
  289. // set hook sound
  290.         hook.think = HookVanish;
  291.         hook.nextthink = time + 5;
  292.  
  293.         setmodel (hook, "progs/star.mdl");
  294.         setsize (hook, '0 0 0', '0 0 0');
  295.         setorigin (hook, self.origin + (v_forward*16) + '0 0 20' );
  296.         sound (self, CHAN_WEAPON, "weapons/chain1.wav", 1, ATTN_NORM);
  297.  
  298. //** PATCH_BEGIN - grap109b - Turrican ****
  299. // Changed the number of links in the chain to 20 from 8. It looks better.
  300.         hook.goalentity = MakeChain (hook, self, 20);
  301. //** PATCH_END - grap109b - Turrican ******
  302. };
  303.